"""
创建/加载字典
"""
import config as cfg
import pickle
import os


def convert_int(arr):
    try:
        return int(arr)
    except ValueError:
        return None


def get_dict_from_data(x_path, intent_path, slot_path):
    """
    从训练数据中获取转换字典
    :return:
    """
    pass


# Intent字典
intent_dict = {}


# Slot字典
with open(os.path.join(cfg.data_path, 'TagDict_alldata.pkl'), 'rb') as f:
    # keys ['tag2index', 'index2tag', 'word2index'] word2index与tag2index重复了
    dictionary = pickle.load(f)
    slot_dict = dictionary['tag2index']
